package Exercise1;

import java.io.*;

public class ReadAndWriterTest {
    public static void main(String args[])
    {
        FileInputStream fileInputStream = null;
        FileOutputStream fileOutputStream = null;
        try {
            File srcFile = new File("src\\微信图片_20220828222640.jpg");
            File destFile = new File("src\\微信图片_202208282226401.jpg");
            fileInputStream = new FileInputStream(srcFile);
            fileOutputStream = new FileOutputStream(destFile);
            byte cubf[] = new byte[1024];
            int len;
            while((len=fileInputStream.read(cubf))!=-1)
            {
                fileOutputStream.write(cubf,0,len);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if(fileInputStream!=null)
            {
                try {
                    fileOutputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if(fileOutputStream!=null)
            {
                try {
                    fileInputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
